// 通用拖拽库主入口

// 导出类型
export type { 
  DragComponentData, 
  DragEventPayload, 
  DropPosition, 
  DragDropConfig,
  ComponentRenderer,
  ComponentRegistry
} from './types'

// 导出工具
export { dragBus, dragEventBus } from './utils/dragBus'

// 导出组件
export { SourceBox } from './components/SourceBox'
export { DropZone } from './components/DropZone'

// 创建一个简单的拖拽管理器
export class DragDropManager {
  private componentRegistry: ComponentRegistry = {}

  registerComponent(type: string, renderer: ComponentRenderer) {
    this.componentRegistry[type] = renderer
  }

  unregisterComponent(type: string) {
    delete this.componentRegistry[type]
  }

  renderComponent(data: DragComponentData) {
    const renderer = this.componentRegistry[data.type]
    if (!renderer) {
      console.warn(`No renderer found for component type: ${data.type}`)
      return null
    }
    
    return renderer(data)
  }

  getRegisteredTypes() {
    return Object.keys(this.componentRegistry)
  }
}

// 创建默认实例
export const defaultDragDropManager = new DragDropManager()